package wql.aaa.controller;

import com.aaa.entity.TbBanner;
import com.aaa.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import wql.aaa.service.TbBannerService;
import wql.aaa.vo.BannerFormDta;
import wql.aaa.vo.SearchFormsData;

/**
 * @author wql
 * @version 1.0
 * @date 2023/2/28 11:36
 */
@RestController
@RequestMapping("/home/banner")
public class BannerController {
    @Autowired
    private TbBannerService tbBannerService;
    @PostMapping("/rotationSearch/{currentPage}/{pageSize}")
    public Result find(@PathVariable Integer currentPage,@PathVariable  Integer pageSize, @RequestBody BannerFormDta bannerFormDta){
        return tbBannerService.queryAll(currentPage,pageSize,bannerFormDta);
    }

    @PostMapping("/addBanner")
    public Result addBanner(@RequestBody TbBanner tbBanner){
        return  tbBannerService.addBanner(tbBanner);
    }

    @PostMapping("/changeStatus/{isDisable}/{id}")
    public Result changeStatus(@PathVariable Integer isDisable,@PathVariable String id){
        return tbBannerService.updateIsDisabled(isDisable,id);
    }

    @GetMapping("/deleteBanner/{id}")
    public Result deleteBanner(@PathVariable String id){
        return tbBannerService.deleteByBannerId(id);
    }

    @PostMapping("/editBanner")
    public Result update(@RequestBody TbBanner tbBanner){
        return tbBannerService.updateLunBoTu(tbBanner);
    }
}
